//
//  MIDImusicController.m
//  迷笛
//
//  Created by . on 2018/9/10.
//  Copyright © 2018年 🍃🌺🌺🍃. All rights reserved.
//

#import "MIDImusicController.h"
#import "MIDImusicViewCell.h"
@interface MIDImusicController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView * Hottable;


@end

@implementation MIDImusicController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIBarButtonItem *leftBarItem = [[UIBarButtonItem alloc] initWithTitle:nil style:UIBarButtonItemStylePlain target:self action:@selector(Block:)];
    self.navigationItem.leftBarButtonItem = leftBarItem;
    
    [self.navigationItem.leftBarButtonItem setImage:[[UIImage imageNamed:@"后退"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [self HomeUI];

}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
{
    return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
    static NSString * cellID = @"cell";
    MIDImusicViewCell * cell =[tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell)
    {
        cell=[[MIDImusicViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
        cell.backgroundColor = [UIColor colorWithHexString:@"#1B212F"];
        [_Hottable setSeparatorColor : [UIColor blackColor]];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;

    }
    cell.song.text = @"生来仿徨";
    cell.singer.text = @"汪峰";
//    [cell.play addTarget:self action:@selector(playBtn:) forControlEvents:UIControlEventTouchUpInside];
    [cell.remove addTarget:self action:@selector(removebtn:) forControlEvents:UIControlEventTouchUpInside];
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 1;
}
- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
{
    return nil;
}
- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;
{
    return nil;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 65;
}

-(void)removebtn:(UIButton * )sender
{
    UIAlertController *controller=[UIAlertController alertControllerWithTitle:@"删除歌曲" message:@"确认将该歌曲从“我的收藏”中移除？" preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction *act1=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    [act1 setValue:[UIColor colorWithHexString:@"#171717"] forKey:@"titleTextColor"];

    UIAlertAction *act2=[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    [act2 setValue:[UIColor colorWithHexString:@"#FF005D"] forKey:@"titleTextColor"];

    [controller addAction:act1];
    [controller addAction:act2];
    [self presentViewController:controller animated:YES completion:^{
        
    }];
}
// 返回上一级
-(void)Block:(UIButton * )sender
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = YES;
    self.navigationController.navigationBar.translucent = NO;//Bar的模糊效果，默认为YES
    
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:@"#171717"];
    self.title = @"我的收藏";
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#FFFFFF"],NSFontAttributeName : [UIFont fontWithName:@"Helvetica-Bold" size:WidthScale(17)]}];
    //    去掉导航黑线
    UIImage *img = [UIImage imageNamed:@""];
    [self.navigationController.navigationBar setBackgroundImage:img  forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
}
-(void)HomeUI
{
    [self.view addSubview:self.Hottable];
}
-(UITableView *)Hottable
{
    if (!_Hottable)
    {
        _Hottable = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height- 65) style:UITableViewStyleGrouped];
        _Hottable.dataSource = self;
        _Hottable.delegate = self;
        _Hottable.backgroundColor = [UIColor colorWithHexString:@"#1B212F"];
    }
    return _Hottable;
}
@end
